//
//  CancelOrderView.m
//  WuJieLive
//
//  Created by iMac on 2017/12/22.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "CancelOrderView.h"
#import "OrderCancelCell.h"

@implementation CancelOrderView

-(void)awakeFromNib
{
    [super awakeFromNib];
    self.index = -1;
    self.tableview.dataSource = self;
    self.tableview.delegate = self;
    self.tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableview registerNib:[UINib nibWithNibName:@"OrderCancelCell" bundle:nil] forCellReuseIdentifier:@"OrderCancelCell"];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    self.titleLabel.text = self.titleString;
    return 1;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.index = indexPath.row;
    OrderCancelCell * cell = [tableView cellForRowAtIndexPath:indexPath];
    self.currentBtn.selected = NO;
    self.currentBtn = cell.selectedBtn;
    self.currentBtn.selected = YES;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    OrderCancelCell * cell = [tableView dequeueReusableCellWithIdentifier:@"OrderCancelCell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.reasonLabel.text = self.dataArray[indexPath.row];
    return cell;
}

- (IBAction)doneAction:(UIButton *)sender {
    if (self.index != -1) {
        if (self.doneBlock) {
            self.doneBlock(self.index);
        }
    }
}
- (IBAction)bgBtnAction:(UIButton *)sender {
    [self removeFromSuperview];
}

@end
